$(function () {

    $("#submit").click(function uploadPicture() {
        var data = new FormData($("#upload")[0])
        data.append("check", 0);
        console.log(data);
        $.ajax({
            type: "POST",
            url: "/blog/users/upload",
            data: data,
            "contentType": false,
            "processData": false,
            dataType: "json",
            success: function (response) {
                if (response.state == 401) {
                    check1 = confirm(response.message);
                    if (check1) {
                        var data1 = new FormData($("#upload")[0]);
                        data1.append("check", 1);
                        $.ajax({
                            type: "POST",
                            url: "/blog/users/upload",
                            data: data1,
                            "contentType": false,
                            "processData": false,
                            dataType: "json",
                            success: function (response) {
                                alert(response.message);
                            }
                        });
                    }
                } else {
                    alert(response.message)
                }

            }
        });
    })

})